import { ref } from 'vue'
import { defineStore } from 'pinia'

export const useCameraStore = defineStore(
  'camera',
  () => {
    const capturedImage = ref(null);
    const liveFormData = ref({});

    const setCapturedImage = (file) => {
      capturedImage.value = file;
    }

    const getCapturedImage = () => {
      const value = capturedImage.value;
      capturedImage.value = null;
      return value;
    }

    const setLiveFormData = (formData) => {
      liveFormData.value = formData;
    }

    const getLiveFormData = () => {
      const form = liveFormData.value;
      liveFormData.value = {};
      return form;
    }

    return {
      setCapturedImage,
      getCapturedImage,
      setLiveFormData,
      getLiveFormData
    }
  }
)